<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="com.kylin.module.shop.business.*,
				 com.kylin.module.shop.orm.*,
				 com.kylin.common.Constants,
				 com.kylin.module.user.orm.*,
				 com.kylin.common.util.*,
				 com.kylin.module.community.orm.*" %>
<%@ include file="/common/include/taglibs.jsp"%>
<%@ include file="/common/include/pageExpires.jsp"%>
<%@ include file="/common/include/dictNames.jsp"%>
<script type="text/javascript" src="/script/validate.js"></script>

<script type="text/javascript" >

function checkSubmit(){
	var theForm = document.InquiryForm;
    if(theForm.username.value == ""){
        alert("<bean:message key="regcompany.02" />不能为空")
        theForm.username.focus();
        return false;
    }
    
    if(theForm.name.value == ""){
        alert("<bean:message key="regcompany.03" />不能为空");
        theForm.name.focus();
        return false;
    }
    if( ListIsSelected(theForm.otherLanguages) == false){
        alert("<bean:message key="regcompany.04" />不能为空")
        return false;
    }
    if( ListIsSelected(theForm.mainbusiness) == false){
        alert("<bean:message key="regcompany.05" />不能为空")
        return false;
    }

    if(theForm.name.value.length > 100){
        alert("公司名称要求不超过 50 个 汉字");
        theForm.name.focus();
        return false;
    }
	if( 
	   (theForm.phoneCountry.value != "" && !isNumber(theForm.phoneCountry.value))
	 ||(theForm.phoneArea.value!= "" && !isNumber(theForm.phoneArea.value))
	 ||(theForm.phone.value.value != "" && !isNumber(theForm.phone.value)) 
	){
        alert("电话号码要求为数字")
        return false;
	}

    if(theForm.email.value != "" && !isEMail(theForm.email.value) ){
        alert("email 格式错误");
        theForm.email.focus();
        return false;
    }
    return true;
}
</script>
<%

	String[] ids = request.getParameterValues("ids"); 

%>
<table class="tl05" align="center" cellspacing="0" cellpadding="0">
<tr>
<td class="tl05ms" valign="top">
<div class="boxtitle">发送询盘信息</div>
<div class="box"><br>
<html:form action="/module/shop/inquiry.do?CMD=saveInquiry" method="post" onsubmit="return checkSubmit()">
  <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td><p>您要咨询的产品名称如下：</p><p>
<%
	if(ids.length > 0)
	{
		for(int i=0;i<ids.length;i++)
		{
	    	Product p = new CompanyBlogic().getProduct(ids[i]);
%>
	  <input type="hidden" name="ids" value="<%=p.getId()%>">
      <img src="/images/arrowy.gif" width="11" height="11" align="absmiddle">
      	<a href="/module/shop/_nodeco/shop.do?CMD=productDetail&id=<%=p.getId()%>" target="_blank">
      		<%=p.getName() %>
		</a>&nbsp;&nbsp;&nbsp;&nbsp;
<%
		}
	}
%>
      </td>
    </tr>
  </table>
  <br>
<%
	User currUser = (User)session.getAttribute(Constants.CURR_USER);
	if(currUser == null)
	{
%>
<input type="hidden" name="language" value="<%=sessionLocale.toString() %>">
  <table width="90%"  border="0" align="center" cellpadding="0" cellspacing="2">
    <tr>
      <td width="160" align="right">主题：</td>
      <td><input name="title" type="text" size="40">
        *</td>
    </tr>
    <tr>
      <td align="right">内容：</td>
      <td><textarea name="contents" cols="60" rows="6"></textarea>
      *</td>
    </tr>
    <tr>
      <td align="right">联系人：</td>
      <td><input name="linkman" type="text" size="40">
        <select name="gender">
        	<option value="1" selected>先生</option>
        	<option value="2">女士</option>
        </select>
        <mytag:select name="fkPositionId" notEmpty="true" dictName="<%=dict_position%>"/>
      *</td>
    </tr>
    <tr>
      <td align="right">公司名称：</td>
      <td><input name="companyname" type="text" size="40">
      *</td>
    </tr>
    <tr>
      <td align="right">公司站点：</td>
      <td><input name="website" type="text" size="40">
      </td>
    </tr>
    <tr>
      <td align="right">联系邮箱：</td>
      <td><input name="email" type="text" size="40">*
          <input type="submit" name="Submit" value="验证邮箱">点击验证邮箱获得验证码</td>
    </tr>
    <tr>
      <td align="right">主营业务：</td>
      <td><mytag:select name="mainbussiness" notEmpty="true" multiple="true"
                size="3" dictName="主营业务"/></td>
    </tr>
    <tr>
      <td align="right">所属国家：</td>
      <td><mytag:national name="country" notEmpty="true" 
                  value="<%=sessionLocale.toString()%>" dictName="<%=Constants.ALLCOUNTRY%>"/>
      * </td>
    </tr>
    <tr>
      <td align="right">联系电话：</td>
      <td><input name="countryphone" type="text" size="10">
      <input name="areaphone" type="text" size="10">
      <input name="phone" type="text" size="10">
      </td>
    </tr>
    <tr>
      <td align="right">验证码：</td>
      <td><input name="validationCode" type="text" size="40">
      * </td>
    </tr>
<%
}if(currUser != null)
{
	if(currUser.getUserrole().equals(Constants.USER_ROLE_COMPANY))
	{
		Company company = new MemberDAO().findCompany(currUser);
%>
<table width="90%"  border="0" align="center" cellpadding="0" cellspacing="2">
    <tr>
      <td width="160" align="right">主题：</td>
      <td><input name="title" type="text" size="40">
        *</td>
    </tr>
    <tr>
      <td align="right">内容：</td>
      <td><textarea name="contents" cols="60" rows="6"></textarea>
      *</td>
    </tr>
    <tr>
      <td align="right">联系人：</td>
      <td><input name="linkman" type="text" size="40" value="<%=JspHelper.checkNull(company.getContact())%>">
        <select name="gender">
        	<option value="1" selected>先生</option>
        	<option value="2">女士</option>
        </select>
        <mytag:select name="fkPositionId" notEmpty="true" dictName="<%=dict_position%>"/>
      *</td>
    </tr>
    <tr>
      <td align="right">公司名称：</td>
      <td><%=JspHelper.checkNull(company.getName())%></td>
    </tr>
    <tr>
      <td align="right">公司站点：</td>
      <td><input name="website" type="text" size="40">
      </td>
    </tr>
    <tr>
      <td align="right">联系邮箱：</td>
      <td><input name="email" type="text" size="40" value="<%=JspHelper.checkNull(company.getEmail())%>">
    </tr>
    <tr>
      <td align="right">主营业务：</td>
      <td><mytag:select name="mainbussiness" notEmpty="true" multiple="true"
                size="3" dictName="主营业务"/></td>
    </tr>
    <tr>
      <td align="right">所属国家：</td>
      <td><%=UTool.getCountryName(currUser.getCountry(),sessionLocale)%></td>
    </tr>
    <tr>
      <td align="right">联系电话：</td>
      <td><input name="countryphone" type="text" size="10" value="<%=JspHelper.checkNull(company.getPhoneCountry())%>">
      <input name="areaphone" type="text" size="10" value="<%=JspHelper.checkNull(company.getPhoneArea())%>">
      <input name="phone" type="text" size="10" value="<%=JspHelper.checkNull(company.getPhoneArea())%>">
      </td>
    </tr>
<%
	}if(currUser.getUserrole().equals(Constants.USER_ROLE_MEMBER))
	{
		Member member = new MemberDAO().findme(currUser);
%>
<table width="90%"  border="0" align="center" cellpadding="0" cellspacing="2">

    <tr>
      <td width="160" align="right">主题：</td>
      <td><input name="title" type="text" size="40">
        *</td>
    </tr>
    <tr>
      <td align="right">内容：</td>
      <td><textarea name="contents" cols="60" rows="6"></textarea>
      *</td>
    </tr>
    <tr>
      <td align="right">联系人：</td>
      <td><input name="linkman" type="text" size="40">
        <select name="gender">
        	<option value="1" selected>先生</option>
        	<option value="2">女士</option>
        </select>
        <mytag:select name="fkPositionId" notEmpty="true" dictName="<%=dict_position%>"/>
      *</td>
    </tr>
    <tr>
      <td align="right">公司名称：</td>
      <td><input name="companyname" type="text" size="40">
      *</td>
    </tr>
    <tr>
      <td align="right">公司站点：</td>
      <td><input name="website" type="text" size="40">
      </td>
    </tr>
    <tr>
      <td align="right">联系邮箱：</td>
      <td><input name="email" type="text" size="40" value="<%=JspHelper.checkNull(currUser.getEmail())%>">
    </tr>
    <tr>
      <td align="right">主营业务：</td>
      <td><mytag:select name="mainbussiness" notEmpty="true" multiple="true"
                size="3" dictName="主营业务"/></td>
    </tr>
    <tr>
      <td align="right">所属国家：</td>
      <td><%=UTool.getCountryName(currUser.getCountry(),sessionLocale)%></td>
    </tr>
    <tr>
      <td align="right">联系电话：</td>
      <td><input name="countryphone" type="text" size="10">
      <input name="areaphone" type="text" size="10">
      <input name="phone" type="text" size="10">
      </td>
    </tr>
    
<%
	}
}
%>

    <tr align="center" valign="bottom">
      <td height="40" colspan="2"><input type="submit" name="Submit" value="提交" onclick="return checkSubmit()"></td>
    </tr>
  </table>
  </html:form>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
